Skip to content

Conversation

@adamwathan
Copy link
Owner

This was pretty damn hard to figure out but Netlify had a good (albeit also awful but that's not their fault, it's the web's) solution.

Basically the challenge is how do you make a modal perfectly centered when there's room, but have the modal area scroll if the modal is too tall?

The solution ends up being using inline-block for the modal itself and putting it next to an extra element that's also inline-block and has a height of 100vh but width: 0, and making them both vertical-align: middle. You don't need flexbox to do the centering at all using this approach but the whole thing definitely feels terrifying.

Check out the deploy preview and test it out and let me know if I missed anything!

@mattellig
Copy link

Firefox quirk I think, but the backdrop covers the scrollbar and prevents scrolling. It also no longer appears to be clickable (doesn't close the modal when clicked).

@adamwathan
Copy link
Owner Author

Thanks! I just pushed an update that seems to work better, let me know how it works for you if you take a look 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants